﻿using System;
using System.Collections.Generic;
using Myotragus.Data.Domain;
using Myotragus.Data.Metadata;
using Myotragus.Data.Util;

namespace Myotragus.Data.Emit
{
	public class LoadEntityGenerator : LocalizableOperationEntityGenerator, ILoadEntityGenerator
	{
		protected static readonly Type TypeOfTextList = typeof(IList<LocalizableTextValue>);

		public LoadEntityGenerator(IDynamicAssembly dynamicAssembly, INameGenerator nameGenerator,
			ILocalizableEntityMapping mapping)
			: base(dynamicAssembly, nameGenerator, mapping)
		{
		}

		protected static readonly Type TypeOfILoadEntity = typeof(ILoadEntity<>);

		protected override Type BaseInterfaceType
		{
			get { return TypeOfILoadEntity; }
		}

		protected override void AttachLocalizableProperty(IDynamicType type, string propertyName)
		{
			type.DefineAutomaticProperty(propertyName, TypeOfTextList);
		}
	}
}